import com.lijinjiang.beautyeye.BeautyEyeLNFHelper;
import com.lijinjiang.beautyeye.ch3_button.BEButtonUI;
import javax.swing.*;
import java.awt.event.ActionEvent;

/**
 * @ClassName Demo01
 * @Description TODO
 * @Author Li
 * @Date 2022/9/13 3:33
 * @ModifyDate 2022/9/13 3:33
 * @Version 1.0
 */
public class Demo01 {
    public static void main(String[] args) {
        try {
            BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
            BeautyEyeLNFHelper.launchBeautyEyeLNF();
        } catch (Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame();
        frame.setTitle("Demo01"); // 设置窗口标题
        frame.setSize(400, 360); // 设置窗口显示大小-
        JPanel panel = new JPanel();
        panel.setLayout(null);
        /* 1.消息对话框（提示消息） */
        JButton button1 = new JButton("showMessageDialog(提示)");
        button1.setBounds(100, 20, 180, 30);
        button1.addActionListener(e -> JOptionPane.showMessageDialog(frame, "这是一条提示信息",
                "标题1", JOptionPane.INFORMATION_MESSAGE));

        /* 2.消息对话框（警告消息） */
        JButton button2 = new JButton("showMessageDialog(警告)");
        button2.setBounds(100, 70, 180, 30);
        button2.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
        button2.addActionListener(e -> JOptionPane.showMessageDialog(frame, "警告！警告！",
                "标题2", JOptionPane.WARNING_MESSAGE));

        /* 3.确认对话框 */
        JButton button3 = new JButton("showConfirmDialog");
        button3.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.lightBlue));
        button3.setBounds(100, 120, 180, 30);
        button3.addActionListener(e -> {
            int res = JOptionPane.showConfirmDialog(frame, "确认要删除？",
                    "标题3", JOptionPane.YES_NO_CANCEL_OPTION);
            System.out.println("选择的结果：" + res);
        });

        /* 4.输入对话框（文本输入） */
        JButton button4 = new JButton("showInputDialog(输入)");
        button4.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red));
        button4.setBounds(100, 170, 180, 30);
        button4.addActionListener(e -> {
            String input = JOptionPane.showInputDialog(frame, "请输入访问密码",
                    "标题4", JOptionPane.WARNING_MESSAGE);
            System.out.println("输入的内容：" + input);
        });

        /* 5.输入对话框（下拉框选择） */
        JButton button5 = new JButton("showInputDialog(下拉)");
        button5.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue));
        button5.setBounds(100, 220, 180, 30);
        button5.addActionListener(e -> {
            Object[] selectValues = new Object[]{"春季", "夏季", "秋季", "冬季"};
            Object value = JOptionPane.showInputDialog(frame, "请选择最喜欢的季节：",
                    "标题5", JOptionPane.PLAIN_MESSAGE, null, selectValues, selectValues[0]);
            System.out.println("选择的内容：" + value);
        });

        /* 6.选项对话框 */
        JButton button6 = new JButton("showOptionDialog");
        button6.setBounds(100, 270, 180, 30);
        button6.addActionListener((ActionEvent e) -> {
            Object[] options = new Object[]{"上午", "下午"};
            int optionSelected = JOptionPane.showOptionDialog(frame, "请选择合适的时间",
                    "标题6", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE,
                    null, options, options[0]);
            if (optionSelected >= 0) {
                System.out.println("选择的按钮：" + options[optionSelected]);
            }
        });

        panel.add(button1);
        panel.add(button2);
        panel.add(button3);
        panel.add(button4);
        panel.add(button5);
        panel.add(button6);
        frame.add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设置窗口默认关闭操作
        frame.setLocationRelativeTo(null); // 相对屏幕居中
        frame.setVisible(true); // 设置窗口可见
    }
}
